#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
const int MOD = 998244353;

mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int n, m;
int a[N];
ll fac[N], inv[N];
ll fastpow(ll b, ll p) {
  ll res = 1;
  while (p) {
    if (p & 1) res = res * b % MOD;
    b = b * b % MOD;
    p >>= 1;
  }
  return res;
}
void init(int n) {
  fac[0] = 1;
  rep(i, 1, n) fac[i] = fac[i - 1] * i % MOD;
  inv[n] = fastpow(fac[n], MOD - 2);
  per(i, n - 1, 0) inv[i] = inv[i + 1] * (i + 1) % MOD;
}
ll C(ll n, ll m) {
  if (n < 0 || m > n) return 0;
  return fac[n] * inv[m] % MOD * inv[n - m] % MOD;
}
void solve() {
  cin >> n;
  rep(i, 1, n) cin >> a[i];
  rep(i, (n + 1) / 2 + 1, n) {
    if (a[i]) {
      cout << 0 << endl;
      return;
    }
  }
  ll sum = accumulate(a + 1, a + n + 1, 0ll);
  if (sum != n) {
    cout << 0 << endl;
    return;
  }
  int tot = 0;
  ll ans = 1;
  per(i, (n + 1) / 2, 1) {
    int left = i, right = n + 1 - left;
    if (left == right)
      tot += 1;
    else
      tot += 2;
    ans = ans * C(tot, a[i]) % MOD;
    tot -= a[i];
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  init(2e5);
  int t;
  cin >> t;
  while (t--) solve();
  return 0;
}